package com.huya.mapper;

import com.github.pagehelper.Page;
import com.huya.pojo.dto.TestPageQueryDTO;
import com.huya.pojo.entity.PsychologicalTest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PsychologicalTestMapper {

    /**
     * 查询所有测试
     * @return
     */
    @Select("SELECT * FROM psychological_tests")
    List<PsychologicalTest> selectAll();

    /**
     * 根据id查询测试
     * @param testId
     * @return
     */
    @Select("SELECT * FROM psychological_tests WHERE test_id = #{testId}")
    PsychologicalTest selectTestById(Long testId);

    /**
     * 根据测试id查询得分规则
     * @param testId
     * @return
     */
    @Select("SELECT scoring_rules FROM psychological_tests WHERE test_id = #{testId}")
    String getScoreRuleByTestId(Long testId);

    /**
     * 分页查询测试
     * @param testPageQueryDTO
     * @return
     */
    Page<PsychologicalTest> pageQuery(TestPageQueryDTO testPageQueryDTO);

    void insert(PsychologicalTest psychologicalTest);

    @Delete("DELETE FROM psychological_tests WHERE test_id = #{testId}")
    void deleteById(Long testId);
}
